#ifndef  _UDPSERVER_H_
#define  _UDPSERVER_H_

#include "../define/define.h"
#include "usocket.h"
#include "udpunit.h"

const uint8   UPDHeadSize    = 5;
const uint8   UDPVer         = 2;

class uthread;

class UDPSINK
{
public:
	virtual void OnRead(uint32 ip,uint16 port,char* buf,int buf_size) = 0;
	virtual void OnReadError(uint32 ip,uint16 port,char* buf,int buf_size) = 0;
};

class UDPServer
{
public:

	UDPServer();
	~UDPServer();

	bool init(uint16 d_port,UDPSINK* udpsink);
	bool sendbuf(uint32 ip, uint16 port, char* buf, uint32 buf_size);
	
	uint16 get_port();
	
private:

	uint16    m_port;
	usocket   m_udp;
	uthread*  m_thread;

};
#endif
